package com.stek.lib;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public abstract class StickyGridHeadersAdapter<T> extends BaseAdapter implements
		StickyGridHeadersSimpleAdapter {
	protected Context mContext;
	protected LayoutInflater mInflater;
	protected List<T> mItems;

	public StickyGridHeadersAdapter(Context context,List<T> items) {
		this.mItems = items;
		this.mContext = context;
		this.mInflater = LayoutInflater.from(mContext);
	}

	@Override
	public boolean areAllItemsEnabled() {
		return false;
	}

	@Override
	public int getCount() {
		return mItems.size();
	}

	@Override
	abstract public String getHeaderField(int position);

	@Override
	abstract public View getHeaderView(int position, View convertView,
			ViewGroup parent);

	@Override
	public T getItem(int position) {
		if (mItems.size() == 0) {
			return null;
		}
		return mItems.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	abstract public View getView(int position, View convertView,
			ViewGroup parent);

	public String getHeaderString(T item) {
		String header = item.toString();
		return header;
	}
}
